package com.whw.springboot.walk.service.servicelmpl;

import com.whw.springboot.walk.entity.Location;
import com.whw.springboot.walk.entity.Message;
import com.whw.springboot.walk.mapper.LocationMapper;
import com.whw.springboot.walk.service.LocationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LocationServiceImpl implements LocationService {

    @Resource
    private LocationMapper locationMapper;

    @Override
    public Message<?> addLocation(Location location) {
        return locationMapper.addLocation(location)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message<?> delLocation(String locationId) {
        return locationMapper.delLocation(locationId)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message<?> update(Location location) {
        return locationMapper.updateLocation(location)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message<Location> findLocationByName(String locationName) {
        return Message.success(null).add(locationMapper.findLocationByName(locationName));
    }

    @Override
    public Message<List<Location>> findAllLocation() {
        return Message.success(null).add(locationMapper.findAllLocation());
    }
}
